/**
 * Project of Vehicle Routing Problem with Time Windows implements 
 * some of well-known algorithms for solving VRPTW.
 *
 * @author Michal Drobny  
 */
package logic.route;

import util.Cloneable;
import logic.destination.Destination;

/**
 * Represents the simple path between two destinations. The destination should
 * be direct neighbors. This class contains information about both destinations.
 * 
 * @author Michal Drobny
 * @date 2.10.2014
 */
public class Path implements Cloneable<Path> {

	private final Destination start;
	private final Destination target;

	/**
	 * @param start
	 * @param target
	 */
	public Path(Destination start, Destination target) {
		super();
		this.start = start;
		this.target = target;
	}

	/**
	 * @return the start
	 */
	public Destination getStart() {
		return start;
	}

	/**
	 * @return the target
	 */
	public Destination getTarget() {
		return target;
	}
	
	@Override
	public Path clone() {
		Destination clonedStart, clonedEnd;
		
		if (getStart() == null)
			clonedStart = null;
		else
			clonedStart = getStart().clone();
		
		if (getTarget() == null)
			clonedEnd = null;
		else
			clonedEnd = getTarget().clone();
		
		return new Path(clonedStart, clonedEnd);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((start == null) ? 0 : start.hashCode());
		result = prime * result + ((target == null) ? 0 : target.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Path)) {
			return false;
		}
		Path other = (Path) obj;
		if (start == null) {
			if (other.start != null) {
				return false;
			}
		} else if (!start.equals(other.start)) {
			return false;
		}
		if (target == null) {
			if (other.target != null) {
				return false;
			}
		} else if (!target.equals(other.target)) {
			return false;
		}
		return true;
	}
	
	
}